package com.wyx.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wyx.mapper.TArticleMapper;
import com.wyx.pojo.TArticle;
import com.wyx.service.TArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class TArtcleServiceImpl implements TArticleService {
    @Autowired
    private TArticleMapper tArticleMapper;


    public List<TArticle> findAll() {

        PageHelper.startPage(1,2);
        List<TArticle> tArticles = tArticleMapper.findAll();

        PageInfo<TArticle> pageInfo = new PageInfo<>(tArticles);
        System.out.println("总条数："+pageInfo.getTotal());
        System.out.println("总页数："+pageInfo.getPages());
        System.out.println("当前页："+pageInfo.getPageNum());
        System.out.println("每页显示的条数："+pageInfo.getPageSize());

//        return tArticleMapper.findAll();


        return tArticles;

    }

    public List<TArticle> findByPage(int pageNum) {

        PageHelper.startPage(pageNum,2);
        List<TArticle> tArticles = tArticleMapper.findAll();

        return tArticles;

    }



}
